package org.xiaoai.other;

public class MyThread implements Runnable {

    private int count = 10;
	
	@Override
	public void run() {
		
		
			//System.out.println("多线程执行了：" + Thread.currentThread().getName());
			
			for(int i = 0; i < count; i++){
				//System.out.println("多线程执行了：" + Thread.currentThread().getName()+","+i);
			
					if(i % 2 == 0){
						
						synchronized (this) {
							System.out.println("多线程执行了：" + Thread.currentThread().getName()+","+i);
							try {
								wait();
							} catch (InterruptedException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						
					}else{
						//System.out.println("多线程执行了：" + Thread.currentThread().getName()+","+i);
						
						try {
							//wait();
							//System.out.println("多线程执行了：" + Thread.currentThread().getName()+","+i);
							
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						
					}
				
				
				
			
			
			
			
			
			
		}
		
			
			
			
			
		}
	

}
